package com.yazi.mxz.client;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import mo.framework.smh.hibernate.OrderType;
import mo.framework.smh.hibernate.PageInfo;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonGenerator.Feature;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.hcd365.hcd.client.ClientFactory;
import com.hcd365.hcd.common.entity.beans.Ad;
import com.hcd365.hcd.common.entity.beans.Address;
import com.hcd365.hcd.common.entity.beans.Category;
import com.hcd365.hcd.common.entity.beans.Member;
import com.hcd365.hcd.common.entity.beans.Order;
import com.hcd365.hcd.common.entity.beans.Region;
import com.hcd365.hcd.common.entity.beans.Shopping;
import com.hcd365.hcd.common.entity.beans.Store;
import com.hcd365.hcd.common.entity.beans.StoreGoods;
import com.hcd365.hcd.common.entity.custom.OrderForSearch;
import com.hcd365.hcd.common.entity.custom.OrderFromForm;
import com.hcd365.hcd.common.entity.custom.OrdersFromForm;
import com.hcd365.hcd.common.entity.custom.ShoppingCartForOrder;
import com.hcd365.hcd.common.entity.custom.ShoppingCartsForOrder;
import com.hcd365.hcd.server.request.AddSecurityQuestionDoRequest;
import com.hcd365.hcd.server.request.ListRequest;
import com.hcd365.hcd.server.request.UpdateOrderStatusRequest;
import com.hcd365.hcd.server.request.UpdatePwdDoRequest;
import com.hcd365.hcd.server.response.AdListResponse;
import com.hcd365.hcd.server.response.AddressListResponse;
import com.hcd365.hcd.server.response.AddressResponse;
import com.hcd365.hcd.server.response.CategoryListResponse;
import com.hcd365.hcd.server.response.IntegerResponse;
import com.hcd365.hcd.server.response.MemberNoticeListResponse;
import com.hcd365.hcd.server.response.MemberResponse;
import com.hcd365.hcd.server.response.OrderAddFormResponse;
import com.hcd365.hcd.server.response.OrderAddResponse;
import com.hcd365.hcd.server.response.OrderListResponse;
import com.hcd365.hcd.server.response.RegionListResponse;
import com.hcd365.hcd.server.response.RegisterResponse;
import com.hcd365.hcd.server.response.SecurityQuestionListResponse;
import com.hcd365.hcd.server.response.ShoppingAddResponse;
import com.hcd365.hcd.server.response.ShoppingCartListResponse;
import com.hcd365.hcd.server.response.StatusResponse;
import com.hcd365.hcd.server.response.StoreGoodsListResponse;
import com.hcd365.hcd.server.response.StoreGoodsResponse;
import com.hcd365.hcd.server.response.StoreListResponse;

public class RequestUtil {
	private static JsonFactory f = new JsonFactory();
	static {
		//f.enable(Feature.ESCAPE_NON_ASCII);
	}
	/**
	 * 检查用户名唯一性
	 * @param name 要检查的用户名
	 * @return
	 */
	public static StatusResponse checkName(String name) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("检查用户名唯一性->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();;
			g.writeStringField("name", name);
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("检查用户名唯一性->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return post2("/member/checkName", reqBody, StatusResponse.class);
	}

	public static StoreListResponse listStore() {
		return post2("/store/list", null, StoreListResponse.class);
	}

	/**
	 * 提交注册
	 * @param name 用户名
	 * @param password 密码
	 * @param storeId 店铺ID
	 * @return
	 */
	public static RegisterResponse registerDo(String name, String password, Long storeId) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("注册->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();;
			g.writeStringField("name", name);
			g.writeStringField("password", password);
			g.writeNumberField("storeId", storeId);
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("注册->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return post2("/member/registerDo", reqBody, RegisterResponse.class);
	}

	public static MemberResponse loginDo(String name, String password) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("登录->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();;
			g.writeStringField("name", name);
			g.writeStringField("password", password);
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("登录->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return post2("/member/loginDo", reqBody, MemberResponse.class);
	}
	
	public static StatusResponse updateEmail(Member member) {
		return post("/email/update", member, StatusResponse.class);
	}
	
	public static AdListResponse listAd(Ad ad, PageInfo pageInfo, String searchWord) {
		String reqBody = adReqBody(ad, pageInfo, searchWord);
		return post2("/ad/list", reqBody, AdListResponse.class);
	}
	
	private static String adReqBody(Ad ad, PageInfo pageInfo, String searchWord) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("获取广告->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();
				g.writeObjectFieldStart("queryObject");
					// 终端类型
					if (null != ad.getDevType()) g.writeNumberField("devType", ad.getDevType());
				g.writeEndObject();
				if (null != pageInfo) {
					g.writeObjectFieldStart("pageInfo");
						g.writeNumberField("pageSize", pageInfo.getPageSize());
						g.writeNumberField("nowPage", pageInfo.getNowPage());
						g.writeStringField("orderField", pageInfo.getOrderField());
						g.writeNumberField("orderType", pageInfo.getOrderType().ordinal());
					g.writeEndObject();
				}
				if (null != searchWord) {
					g.writeStringField("searchWord", searchWord);
				}
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("获取广告->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return reqBody;
	}
	
	public static StoreGoodsListResponse listStoreGoods(StoreGoods storeGoods, PageInfo pageInfo, String searchWord) {
		String reqBody = storeGoodsReqBody(storeGoods, pageInfo, searchWord);
		return post2("/storeGoods/list", reqBody, StoreGoodsListResponse.class);
	}
	
	private static String storeGoodsReqBody(StoreGoods storeGoods, PageInfo pageInfo, String searchWord) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("获取商品->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();
				g.writeObjectFieldStart("queryObject");
					// 商品ID
					if (null != storeGoods.getStoreGoodsId()) g.writeNumberField("storeGoodsId", storeGoods.getStoreGoodsId());	
					// 促销类型
					if (null != storeGoods.getPromoteType()) g.writeNumberField("promoteType", storeGoods.getPromoteType());
				
					Store store = storeGoods.getStore();
					if (null != store) {
						g.writeObjectFieldStart("store");
							if (null != store.getStoreId()) g.writeNumberField("storeId", store.getStoreId());
						g.writeEndObject();
					}
					Category cat = storeGoods.getCategoryByCatId();
					if (null != cat) {
						g.writeObjectFieldStart("categoryByCatId");
							if (null != cat.getCatId()) g.writeNumberField("catId", cat.getCatId());
						g.writeEndObject();
					}
					Category cat2 = storeGoods.getCategoryByCatId2();
					if (null != cat2) {
						g.writeObjectFieldStart("categoryByCatId2");
							if (null != cat2.getCatId()) g.writeNumberField("catId", cat2.getCatId());
						g.writeEndObject();
					}
				g.writeEndObject();
				if (null != pageInfo) {
					g.writeObjectFieldStart("pageInfo");
						g.writeNumberField("pageSize", pageInfo.getPageSize());
						g.writeNumberField("nowPage", pageInfo.getNowPage());
						g.writeStringField("orderField", pageInfo.getOrderField());
						g.writeNumberField("orderType", pageInfo.getOrderType().ordinal());
					g.writeEndObject();
				}
				if (null != searchWord) {
					g.writeStringField("searchWord", searchWord);
				}
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("获取商品->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return reqBody;
	}

	public static CategoryListResponse listCategory(Category category, PageInfo pageInfo) {
		String reqBody = categoryReqBody(category, pageInfo);
		return post2("/category/list", reqBody, CategoryListResponse.class);
	}
	
	private static String categoryReqBody(Category cat, PageInfo pi) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("获取分类->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();
			
				g.writeObjectFieldStart("queryObject");
					if (null != cat.getDeep()) g.writeNumberField("deep", cat.getDeep());
					if (null != cat.getType()) g.writeNumberField("type", cat.getType());
				
					Category parent = cat.getCategory();
					if (null != parent) {
						g.writeObjectFieldStart("category");
							if (null != parent.getCatId()) g.writeNumberField("catId", parent.getCatId());
						g.writeEndObject();
					}
				g.writeEndObject();
				
				if (null != pi) {
					g.writeObjectFieldStart("pageInfo");
						g.writeNumberField("pageSize", pi.getPageSize());
						g.writeNumberField("nowPage", pi.getNowPage());
						g.writeStringField("orderField", pi.getOrderField());
						g.writeNumberField("orderType", pi.getOrderType().ordinal());
					g.writeEndObject();
				}
				
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("获取分类->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return reqBody;
	}

	public static StoreGoodsResponse oneStoreGoods(Long storeGoodsId) {
		return post2("/storeGoods/detail", "" + storeGoodsId, StoreGoodsResponse.class);
	}

	public static StoreGoodsListResponse listStoreGoodsFromSameOrder(StoreGoods storeGoods, PageInfo pageInfo) {
		String reqBody = storeGoodsReqBody(storeGoods, pageInfo, null);
		return post2("/storeGoods/listFromSameOrder", reqBody, StoreGoodsListResponse.class);
	}
	
	public static AddressListResponse listAddress() {
		return post2("/address/list", null, AddressListResponse.class);
	}

	public static StatusResponse removeAddress(Long addressId) {
		return post2("/address/removeDo", "" + addressId, StatusResponse.class);
	}

	public static AddressResponse addAddress(Address address) {
		String reqBody = addressAddReqBody(address);
		return post2("/address/addDo", reqBody, AddressResponse.class);
	}

	private static String addressAddReqBody(Address addr) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("添加收货地址->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();
				if (null != addr.getAlias()) g.writeStringField("alias", addr.getAlias());
				if (null != addr.getIsDefault()) g.writeBooleanField("isDefault", addr.getIsDefault());
				if (null != addr.getRegionName()) g.writeStringField("regionName", addr.getRegionName());
				if (null != addr.getStreet()) g.writeStringField("street", addr.getStreet());
				if (null != addr.getConsignee()) g.writeStringField("consignee", addr.getConsignee());
				if (null != addr.getMobile()) g.writeStringField("mobile", addr.getMobile());
				Region region = addr.getRegion();
				if (null != region) {
					g.writeObjectFieldStart("region");
					if (null != region.getRegionId()) g.writeNumberField("regionId", region.getRegionId());
					g.writeEndObject();
				}
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("添加收货地址->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return reqBody;
	}
	
	public static StatusResponse updateDefAddress(Long addressId) {
		return post2("/address/setDefaultDo", "" + addressId, StatusResponse.class);
	}

	public static ShoppingAddResponse addShopping(Shopping shopping) {
		String reqBody = shoppingAddReqBody(shopping);
		return post2("/shopping/addDo", reqBody, ShoppingAddResponse.class);
	}
	
	private static String shoppingAddReqBody(Shopping shopping) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("加入购物车->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();
				if (null != shopping.getBuyCount()) g.writeNumberField("buyCount", shopping.getBuyCount());
				StoreGoods sg = shopping.getStoreGoods();
				if (null != sg) {
					g.writeObjectFieldStart("storeGoods");
					if (null != sg.getStoreGoodsId()) g.writeNumberField("storeGoodsId", sg.getStoreGoodsId());
					g.writeEndObject();
				}
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("加入购物车->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return reqBody;
	}

	public static StatusResponse updateShopping(Shopping shopping) {
		String reqBody = shoppingUpdateReqBody(shopping);
		return post2("/shopping/updateDo", reqBody, StatusResponse.class);
	}
	
	private static String shoppingUpdateReqBody(Shopping shopping) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("更新购物车物品->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();
				g.writeNumberField("shoppingId", shopping.getShoppingId());
				if (null != shopping.getBuyCount()) g.writeNumberField("buyCount", shopping.getBuyCount());
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("更新购物车物品->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return reqBody;
	}

	public static StatusResponse removeShoppings(List<Long> shoppingIds) {
		return post2("/shopping/delDo", shoppingIds.toString(), StatusResponse.class);
	}
	
	public static IntegerResponse countShopping() {
		return post2("/shopping/count", null, IntegerResponse.class);
	}

	public static ShoppingCartListResponse listShoppingCart() {
		return post2("/shoppingCart/list", null, ShoppingCartListResponse.class);
	}

	public static OrderAddFormResponse getOrderFormData(ShoppingCartsForOrder container) {
		String reqBody = orderFormReqBody(container);
		return post2("/order/add", reqBody, OrderAddFormResponse.class);
	}

	private static String orderFormReqBody(ShoppingCartsForOrder container) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("获取订单表单数据->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();
				g.writeArrayFieldStart("shoppingCarts");
					List<ShoppingCartForOrder> carts = container.getShoppingCarts();
					for (ShoppingCartForOrder cart : carts) {
						g.writeStartObject();
							g.writeNumberField("cartId", cart.getCartId());
							g.writeArrayFieldStart("shoppingIds");
								Long[] shoppingIds = cart.getShoppingIds();
								for (Long shoppingId : shoppingIds) {
									g.writeNumber(shoppingId);
								}
							g.writeEndArray();
						g.writeEndObject();
					}
				g.writeEndArray();
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("获取订单表单数据->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return reqBody;
	}
	
	public static OrderAddResponse addOrders(OrdersFromForm orders) {
		String reqBody = addOrdersReqBody(orders);
		return post2("/order/addDo", reqBody, OrderAddResponse.class);
	}
	
	private static String addOrdersReqBody(OrdersFromForm orders) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("提交订单->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();
				g.writeNumberField("addressId", orders.getAddressId());
				g.writeArrayFieldStart("orders");
					List<OrderFromForm> orderList = orders.getOrders();
					for (OrderFromForm order : orderList) {
						g.writeStartObject();
							g.writeNumberField("expressId", order.getExpressId());	
							g.writeNumberField("payTypeId", order.getPayTypeId());
							g.writeArrayFieldStart("shoppingIds");
								Long[] shoppingIds = order.getShoppingIds();
								for (Long shoppingId : shoppingIds) {
									g.writeNumber(shoppingId);
								}
							g.writeEndArray();
							g.writeObjectFieldStart("store");
								g.writeNumberField("storeId", order.getStore().getStoreId());	
							g.writeEndObject();
						g.writeEndObject();
					}
				g.writeEndArray();
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("提交订单->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return reqBody;
	}

	public static RegionListResponse listRegionsByParentId(long regionId) {
		return post2("/region/listByParentId", "" + regionId, RegionListResponse.class);
	}

	public static RegionListResponse listRootRegions() {
		return post2("/region/listByParentId", null, RegionListResponse.class);
	}

	public static RegionListResponse listBrotherRegions(long regionId) {
		return post2("/region/listBrothers", "" + regionId, RegionListResponse.class);
	}

	public static IntegerResponse countMemberNotice() {
		return post2("/memberNotice/count", null, IntegerResponse.class);
	}

	public static MemberNoticeListResponse listMemberNotices(PageInfo pageInfo) {
		String reqBody = memberNoticeListReqBody(pageInfo);
		return post2("/memberNotice/list", reqBody, MemberNoticeListResponse.class);
	}
	
	private static String memberNoticeListReqBody(PageInfo pageInfo) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("获取用户通知列表->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();
				g.writeObjectFieldStart("pageInfo");
					g.writeNumberField("pageSize", pageInfo.getPageSize());
					g.writeNumberField("nowPage", pageInfo.getNowPage());
					g.writeStringField("orderField", pageInfo.getOrderField());
					g.writeNumberField("orderType", pageInfo.getOrderType().ordinal());
				g.writeEndObject();
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("获取用户通知列表->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return reqBody;
	}

	public static StatusResponse removeMemberNotices(List<Long> noticeIds) {
		return post2("/memberNotice/removeDo", noticeIds.toString(), StatusResponse.class);
	}

	public static OrderListResponse listOrders(ListRequest<OrderForSearch> req) {
		return post("/order/list", req, OrderListResponse.class);
	}
	
	public static StatusResponse updateOrderStatus(UpdateOrderStatusRequest req) {
		String reqBody = updateOrderStatusReqBody(req);
		return post2("/order/statusDo", reqBody, StatusResponse.class);
	}
	
	private static String updateOrderStatusReqBody(UpdateOrderStatusRequest req) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("更新订单状态->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();
				g.writeNumberField("status", req.getStatus());
				g.writeArrayFieldStart("orderCodes");
					String[] orderCodes = req.getOrderCodes();
					for (String orderCode : orderCodes) {
						g.writeString(orderCode);
					}
				g.writeEndArray();
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("更新订单状态->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return reqBody;
	}
	
	public static StatusResponse removeOrder(String orderCode) {
		String reqBody = removeOrderReqBody(orderCode);
		return post2("/order/removeDo", reqBody, StatusResponse.class);
	}
	
	private static String removeOrderReqBody(String orderCode) {
		JsonGenerator g = null;
		String reqBody = null;
		System.out.println("删除订单->java2json前:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		try {
			g = f.createGenerator(new StringWriter());
			g.writeStartObject();
				g.writeStringField("orderCode", orderCode);
			g.writeEndObject();
			g.close();
			reqBody = String.valueOf(g.getOutputTarget());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("删除订单->java2json后:" + new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()));
		return reqBody;
	}
	
	public static SecurityQuestionListResponse listSecurityQuestions() {
		return post2("/securityQuestion/list", null, SecurityQuestionListResponse.class);
	}
	
	public static StatusResponse addSecurityQuestionsDo(AddSecurityQuestionDoRequest req) {
		return post("/securityQuestion/addDo", req, StatusResponse.class);
	}
	
	public static StatusResponse updatePwdDo(UpdatePwdDoRequest req) {
		return post("/member/editPwdDo", req, StatusResponse.class);
	}

	private static <T extends StatusResponse> T post(String url, Object requestObject,
			Class<T> responseClass) {
		T t = null;
		try {
			t = ClientFactory.getCurrentClient().post(url, requestObject, responseClass);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return t;
	}
	
	private static <T extends StatusResponse> T post2(String url, String reqBody,
			Class<T> resClass) {
		T t = null;
		try {
			t = ClientFactory.getCurrentClient().post2(url, reqBody, resClass);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return t;
	}

	public static String getPath() {
		return ClientFactory.getConfig().getPath();
	}

	public static void setPath(String path) {
		ClientFactory.getConfig().setPath(path);
	}

	public static void setPrintQueryBody(Boolean bool) {
		ClientFactory.getConfig().setIsPrintBody(true);
	}

}
